<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>SetWinDelay</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SetWinDelay</h1>

<p>Sets the delay that will occur after each windowing command, such as <a href="WinActivate.htm">WinActivate</a>.</p>

<pre class="Syntax">SetWinDelay, Delay</pre>
<h3>Parameters</h3>
<dl>

  <dt>Delay</dt>
  <dd><p>Time in milliseconds, which can be an <a href="../Variables.htm#Expressions">expression</a>. Use -1 for no delay at all and 0 for the smallest possible delay. If unset, the default delay is 100.</p></dd>

</dl>

<h3>Remarks</h3>
<p>A short delay (sleep) is done automatically after every windowing command except <a href="WinActive.htm">IfWinActive</a> and <a href="WinExist.htm">IfWinExist</a>. This is done to improve the reliability of scripts because a window sometimes needs a period of &quot;rest&quot; after being created,  activated, minimized, etc. so that it has a chance to update itself and respond to the next command that the script may attempt to send to it.</p>
<p>Although a delay of -1 (no delay at all) is allowed, it is recommended that at least 0 be used, to increase confidence that the script will run correctly even when the CPU is under load.</p>
<p>A delay of 0 internally executes a Sleep(0), which yields the remainder of the script's timeslice to any other process that may need it. If there is none, Sleep(0) will not sleep at all.</p>
<p>If the CPU is slow or under load, or if window animation is enabled, higher delay values may be needed.</p>
<p>The built-in variable <strong>A_WinDelay</strong> contains the current setting.</p>
<p>Every newly launched <a href="../misc/Threads.htm">thread</a> (such as a <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).</p>
<h3>Related</h3>
<p><a href="SetControlDelay.htm">SetControlDelay</a>, <a href="SetKeyDelay.htm">SetKeyDelay</a>, <a href="SetMouseDelay.htm">SetMouseDelay</a>, <a href="SetBatchLines.htm">SetBatchLines</a>, <a href="SendMode.htm">SendMode</a></p>
<h3>Example</h3>
<pre class="NoIndent">SetWinDelay, 10</pre>

</body>
</html>
